package ore.jiao.explorer;

import java.io.File;

import javax.swing.tree.DefaultMutableTreeNode;

public class MyMutableTreeNode extends DefaultMutableTreeNode {

	public MyMutableTreeNode(Object value){
		super(value);
	}
	
	@Override
	public String toString() {
		
		if (userObject == null) {
			return null;
		}
		if(userObject instanceof File){
			File file = (File) userObject;
			String name = file.toString();
			if(name.length() < 5)	return name;
			int lastIndexOf = name.lastIndexOf(File.separatorChar);
			if(lastIndexOf == -1)	return name;
			return name.substring(lastIndexOf+1);
		}
		return userObject.toString();
	}
}
